<form class="layui-form" lay-filter="add-form" action="{:url('')}" method="post" id="editForm">
	<div class="layui-form-item">
        {:FormExt::setInline()}
        {:FormExt::input('物料SKU', 'material_sku', $info['material_sku'], '请输入物料SKU', '', 'readonly')}
        {:FormExt::select('物料属性', 'stock_m_type','1', ['0' => '常规料', '1' => '备料', '2' => '余料'], '', '')}
        
    <!--    {:FormExt::select('单位', 'unit', $info['unit'], $unitKV, '', '')}-->
        {:FormExt::input('库存数量', 'use_num', '', '请输入数量', 'required', 'lay-verify="number"')}
        {:FormExt::input('布号/物料id', 'cloth_num', '', '请输入物料id', 'required', 'lay-verify=""')}
        {:FormExt::select('* 货仓', 'storehouse_id', '', $storehouseKV, '', 'required', 'lay-filter="storehouse-id"')}
        {:FormExt::input('订单号/采购批号', 'res_id', '', '请输入订单号/采购批号', '', '')}
        {:FormExt::select('工厂', 'factory_id', 0, $factoryKV, '', '')}
        {:FormExt::select('货架', 'storeshelf_id', '', [], '', 'required')}
        {:FormExt::input('备注', 'remark', '', '请输入备注', '', 'lay-verify=""')}
    </div>
    <div class="pop-bottom-bar">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: false, callback: callbackUpdateStock}">提交并入库</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
    <input type="hidden" class="field-id" name="materialid" value="{$info['id']}">
</form>

{include file="system@block/layui" /}
    
<script type="text/javascript">
    var storeshelfMap = {:json_encode($storeshelfMap)};
    layui.use(['tool', 'form'], function() {
    	var $ = layui.jquery;
    	var form = layui.form;
    	$('input[name=metre]').focus();
    	

    	// 表单提交回调
    	window.callbackUpdateStock = function(obj, res) {
			setTimeout(function(){
				parent.layer.closeAll();
			},3000);
    	}
    	// 货仓下拉切换
        form.on('select(storehouse-id)', function(data){
            var optionArr = storeshelfMap[data.value];
            var option = '';
            for(var i in optionArr) {
                option += '<option value="'+i+'">'+optionArr[i]+'</option>';
            }
            $("select[name=storeshelf_id] option").remove();
            $('select[name=storeshelf_id]').append(option);
            form.render();
        });
    });
</script>